package com.gry.mystring;

import java.util.Scanner;

public class StringDemo4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入数字");
        int money = 0;
        int ge = 0;
        while (true) {
            money = sc.nextInt();
            if (money >= 0 && money <= 9999999) {
                break;
            } else {
                System.out.println("金额无效");
            }
        }
        String bigNumber = getBigNumber(money);
        int temp = 7 - bigNumber.length();
        for (int i = 0; i < temp; i++) {
            bigNumber = "零" + bigNumber;
        }
        String[] arr = {"佰", "拾", "万", "仟", "佰", "拾", "元"};
        String result = "";
        for (int i = 0; i < bigNumber.length(); i++) {
            char c = bigNumber.charAt(i);
            result = result + c + arr[i];
        }
        System.out.println(result);
    }

    public static String getBigNumber(int money) {
        String[] s1 = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
        String shuzi = "";
        int ge;
        while (money != 0) {
            ge = money % 10;
            money = money / 10;
            shuzi = s1[ge] + shuzi;
        }
        return shuzi;
    }
}
